<?php
//是否为专家
function isExpert($uid){
	$i = D('space','home')->field('isexpert')->where('uid='.$uid)->find();
	return intval($i['isexpert']);
}

function getCmsCateTitle($id){
	return D('CmsCate')->where("id=".$id)->getField('title');
}

//是否为我的联系人
function isMyColleague($uid){
	return D('Colleague')->where('uid='.$_SESSION['mid'].' AND fid='.$uid)->count();
}

function getBlogTags($tags, $tagsName, $suffix = ",", $url) {
	if (strpos ( $tags, ',' ) === false) {
		$data = array (0 => $tags );
	} else {
		$data = explode ( ',', $tags );
	}
	
	if (strpos ( $tagsName, ',' ) === false) {
		$tagsName = array (0 => $tagsName );
	} else {
		$tagsName = explode ( ',', $tagsName );
	}
	$result = array ();
	foreach ( $data as $key => $value ) {
		$temp = array ();
		$temp = U('search/all/index',"type=blog&key={$tagsName [$key]}");
		$result [] = sprintf ( '<a href="%s">%s</a>', $temp, $tagsName [$key] );
	}
	return implode ( $suffix, $result );
}
/**
 * getBlogShort 
 * 截取blog的长度
 * @param mixed $content 
 * @param mixed $length 
 * @access public
 * @return void
 */
function getBlogShort($content,$length = 60) {
	$content	=	stripslashes($content);
	$content	=	strip_tags($content);
	$content	=	getShort($content,$length);
	return $content;
}

//将二维数组格式化为一维数组
function formatArray($array, $field = 'id') {
	$res = array();
	foreach($array as $v) {
		$res[] = $v[$field];
	}
	return $res;
}
?>